#!/bin/bash

# OEM镜像生成器服务安装脚本

echo "正在安装OEM镜像生成器服务..."

# 检查是否为root用户
if [ "$EUID" -ne 0 ]; then
    echo "错误: 请使用sudo运行此脚本"
    exit 1
fi

# 复制service文件到systemd目录
cp oem-generator.service /etc/systemd/system/

# 重新加载systemd配置
systemctl daemon-reload

# 启用服务开机自启动
systemctl enable oem-generator.service

# 启动服务
systemctl start oem-generator.service

# 检查服务状态
echo "服务状态:"
systemctl status oem-generator.service --no-pager

echo ""
echo "安装完成！"
echo "服务已设置为开机自启动"
echo ""
echo "常用命令:"
echo "  查看服务状态: sudo systemctl status oem-generator.service"
echo "  启动服务: sudo systemctl start oem-generator.service"
echo "  停止服务: sudo systemctl stop oem-generator.service"
echo "  重启服务: sudo systemctl restart oem-generator.service"
echo "  查看日志: sudo journalctl -u oem-generator.service -f"
echo "  禁用开机自启动: sudo systemctl disable oem-generator.service" 